package code.google.jcontainer.support.intercept;

import java.lang.reflect.Method;

/**
 * InterceptContext contains the resources want to use in the Intercept method, {@link Interceptable#beforeMethod(InterceptContext)} and {@link code.google.jcontainer.support.intercept.Interceptable#afterMethod(InterceptContext)}
 *
 * @author <a href="mailto:jfox.young@gmail.com">Young Yang</a>
 */
public interface InterceptContext {

    /**
     * @return the object on which the intercepted method is called.
     */
    Object getTarget();

    /**
     * @return the method that is intercepted (null for lifecycle interceptors).
     */
    Method getMethod();

    /**
     * @return the parameters of the intercepted method (if any)
     */
    Object[] getParameters();

    /**
     * Sets the parameters of the method that is intercepted.
     * @param params the array of parameters.
     */
    void setParameters(Object[] params);

    /**
     * set method result, it will replace the method returned result
     *
     * NOTE: Can not invoke in {@link code.google.jcontainer.support.intercept.Interceptable#beforeMethod(InterceptContext)}
     */
    void setResult(Object result);

    /**
     * get intercepted method returned result
     *
     * NOTE: Can not invoke in {@link code.google.jcontainer.support.intercept.Interceptable#beforeMethod(InterceptContext)}
     */
    Object getResult();

}
